<template>
  <div>
    <el-container>
      <el-header style="padding: 0;">
        <el-container>
          <div style="width: 230px;background-color: #E9EEF3;z-index: 999;">
            <img src="../../assets/logo.png" alt="" style="width: 40px;position: relative; top: 10px;"/>
            <span style="font-size: 20px;margin-left: 15px;color: #545c64;">树苗易售管理系统</span>
          </div>

          <el-main style="padding: 0;z-index: 999;">
            <el-menu
                :default-active="$route.path" router="true"
                class="el-menu-demo"
                mode="horizontal"
                @select="handleSelect"
                background-color="#E9EEF3"
                text-color="#545c64"
                active-text-color="aquamarine">

              <el-menu-item index="/businesshomeview">
                <i class="el-icon-s-home"></i>
                <span>商家首页</span>
              </el-menu-item>

                <el-menu-item index="/othertreeinfoview">
                  <i class="el-icon-collection"></i>
                  <span>树苗信息</span>
                </el-menu-item>

              <el-menu-item index="/userfeedbackinfoview">
                <i class="el-icon-service"></i>
                <span>用户反馈</span>
              </el-menu-item>

              <el-menu-item index="/businessselfview">
                <span>个人中心</span>
              </el-menu-item>

              <el-menu-item index="/businessnotice">
                <i class="el-icon-message"></i>
                <span>系统公告</span>
              </el-menu-item>

              <el-submenu index="4" style="float: right;">
                <template slot="title">
                  <span style="color: #545c64; font-size: 16px; font-weight: bold;">欢迎商家 &nbsp</span>
                  <el-image
                      style="width: 50px; height: 50px;border-radius: 50%;"
                      :src="'http://localhost:8081/api/files/' + user.img">
                  </el-image>
                </template>

                <el-menu-item @click="exit()">
                  <span>退出登录</span>
                </el-menu-item>

              </el-submenu>

            </el-menu>
          </el-main>
        </el-container>
      </el-header>

      <el-main style="padding: 0;">
        <router-view></router-view>
      </el-main>

    </el-container>
  </div>
</template>

<script>
import request from "@/utils/request";

export default {
  name:"businessview",
  data() {
    return {
      user:sessionStorage.getItem("user")? JSON.parse(sessionStorage.getItem("user")):{},
    }
  },
  created() {
    this.reloaduser();
  },
  methods: {

    exit(){
      sessionStorage.removeItem("user");
      this.$router.push('/loginview')
    },
    reloaduser(){
      request.post("/user/reloaduser",this.user).then(res => {
        if (res.code === '0') {
          sessionStorage.setItem("user",JSON.stringify(res.data));
        } else {
          this.$message.error(res.msg);
        }
      })
    },
    handleSelect(){}
  },
};
</script>

<style>
.el-header{
  background-color: #B3C0D1;
  color: #333;
  text-align: center;
  line-height: 60px;
}

.el-aside {
  background-color: #D3DCE6;
  color: #333;
  text-align: center;
  line-height: 200px;
}

.el-main {
  background-color: #E9EEF3;
  color: #333;
  text-align: center;
}

.el-menu {
  border-right:none !important;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}

.el-dropdown-link {
  cursor: pointer;
  color: #ffFFFFFF;
}
.el-icon-arrow-down {
  font-size: 12px;
}

</style>